/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.util.List;
import model.Persoon;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Matthy & Jelle
 */
public class PersoonService extends AbstractService{

  @Override
  public boolean validate(Object o) {
    Persoon p = (Persoon)o;
    return !(p.getNaam().isEmpty() || p.getNaam() == null || p.getVoornaam().isEmpty() || p.getVoornaam() == null);
  }

  public List<Persoon> getPersonen() {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Query query = session.createQuery("from Persoon");
    List<Persoon> personen = query.list();
    session.getTransaction().commit();
    return personen;
  }

}
